package cn.howxu.yichen_ovo.event;

import cn.howxu.yichen_ovo.YiChenOVO;
import cn.howxu.yichen_ovo.init.ModItems;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.monster.Witch;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

import java.util.Random;

/**
 * @description: TODO
 * @author: HowXu
 * @date: 2025/9/22 11:14
 */

@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, modid = YiChenOVO.MODID)
public class EntityDropEvent {
    @SubscribeEvent
    public static void onLivingDropsEvent(LivingDropsEvent event) {
        LivingEntity entity = event.getEntity();
        if (entity instanceof Witch){
            if(new Random().nextInt(100) < 17){
                event.getDrops().add(new ItemEntity(entity.level(),entity.position().x,entity.position().y,entity.position().z,new ItemStack(ModItems.HEART.get(),1)));
            }
        }
    }
}
